package com.zhaodao.dubbo.demo.model;

import com.baomidou.mybatisplus.annotations.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.Max;


/**
 * 用户信息
 *
 * @author jack-cooper
 * @since 2016-01-31 21:39
 */
@ApiModel(description = "用户信息")
public class User extends BaseEntity {

    @NotEmpty(message="用户名不能为空")
    @ApiModelProperty(value = "用户名")
    private String username;

    @ApiModelProperty(value = "密码")
    @NotEmpty(message="密码不能为空")
    private String password;

    @ApiModelProperty(value = "类型")
    private String usertype;

    @ApiModelProperty(value = "是否可用(0不可用1可用)")
    private Integer enabled;

    @ApiModelProperty(value = "联系QQ")
    private String qq;
    @ApiModelProperty(value = "联系邮箱")
    @Email
    private String email;
    @ApiModelProperty(value = "联系电话")
    @Max(value=11, message="不能超过11位")
    private String tel;

    @TableField(exist = false)  //数据库里没有但要用的属性
    private boolean flag;

    public User(){

    }

    public User(User user) {
        this.username = user.getUsername();
        this.password = user.getPassword();
        this.usertype = user.getUsertype();
        this.enabled = user.getEnabled();
        this.qq = user.getQq();
        this.email = user.getEmail();
        this.tel = user.getTel();
        super.setId(user.getId());
        super.setCreated(user.getCreated());
        super.setUpdated(user.getUpdated());
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsertype() {
        return usertype;
    }

    public void setUsertype(String usertype) {
        this.usertype = usertype;
    }

    public Integer getEnabled() {
        return enabled;
    }

    public void setEnabled(Integer enabled) {
        this.enabled = enabled;
    }

    public String getQq() {
        return qq;
    }

    public void setQq(String qq) {
        this.qq = qq;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    @Override
    public String toString() {
        return "User{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", usertype='" + usertype + '\'' +
                ", enabled=" + enabled +
                ", qq='" + qq + '\'' +
                ", email='" + email + '\'' +
                ", tel='" + tel + '\'' +
                '}';
    }
}
